/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package cc.gehua.octopus.rpc.common.classloader;

import cc.gehua.octopus.rpc.common.resource.Resource;
import java.io.IOException;
import java.security.PermissionCollection;

/**
 *
 * @author herui
 */
public interface Context {
    /* ------------------------------------------------------------ */

    /**
     * Convert a URL or path to a Resource. The default implementation is a
     * wrapper for {@link Resource#newResource(String)}.
     *
     * @param urlOrPath The URL or path to convert
     * @return The Resource for the URL/path
     * @throws IOException The Resource could not be created.
     */
    Resource newResource(String urlOrPath) throws IOException;

    /* ------------------------------------------------------------ */
    /**
     * @return Returns the permissions.
     */
    PermissionCollection getPermissions();

    /* ------------------------------------------------------------ */
    /**
     * Is the class a System Class. A System class is a class that is visible to
     * a webapplication, but that cannot be overridden by the contents of
     * WEB-INF/lib or WEB-INF/classes
     *
     * @param clazz The fully qualified name of the class.
     * @return True if the class is a system class.
     */
    boolean isSystemClass(String clazz);

    /* ------------------------------------------------------------ */
    /**
     * Is the class a Server Class. A Server class is a class that is part of
     * the implementation of the server and is NIT visible to a webapplication.
     * The web application may provide it's own implementation of the class, to
     * be loaded from WEB-INF/lib or WEB-INF/classes
     *
     * @param clazz The fully qualified name of the class.
     * @return True if the class is a server class.
     */
    boolean isServerClass(String clazz);

    /* ------------------------------------------------------------ */
    /**
     * @return True if the classloader should delegate first to the parent
     * classloader (standard java behaviour) or false if the classloader should
     * first try to load from WEB-INF/lib or WEB-INF/classes (servlet spec
     * recommendation).
     */
    boolean isParentLoaderPriority();

    /* ------------------------------------------------------------ */
    String getExtraClasspath();

}
